<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <%@include file="/common/common.jsp" %>
    <link rel="stylesheet" href="${basePath}/css/layerPage.css${VERSION}"/>
    <link rel="stylesheet" href="${basePath}/assets/css/foundation-datepicker.css"/>
	<script type="text/javascript" src="${basePath}/assets/js/foundation-datepicker.js"></script>
</head>
<body>
<form id="form" name="form" class="form-horizontal" method="post" action="${basePath}/notice/uploadFile"
      enctype="multipart/form-data">
    <div class="panel-body">
        <div class="form-group">
            <label class="col-sm-3 control-label">通知标题：</label>
            <div class="col-sm-9">
                <input type="text" class="col-sm-5" id="title" name="title"/>

            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">优先级：</label>
            <div class="col-sm-9" style="width:200px">
                <select id="priority" name="priority" class="selectpicker show-tick form-control">
		          	<option value="1" selected >普通</option>
		          	<option value="2">高</option>
		          	<option value="3">紧急</option>
        		</select>
            </div>
        </div>
			       

        <div class="form-group" id="taskUser">
            <label class="col-sm-3 control-label">通知人员：</label>
            <div class="col-sm-9" style="width:120px">
                <input type="hidden" name="alloterId" id="alloterId"/>
                <input type="hidden" name="alloterIds" id="alloterIds"/>
                <input class="col-sm-5" type="text" name="userName" id="userName" data-toggle="dropdown" readonly value= "请选择人员" style="width:400px"/>
                <ul class="dropdown-menu" role="menu" aria-labelledby="userName" style="display: none" >
                    <c:forEach var="item" items="${userTaskVos}" varStatus="status">
                        <li role="presentation" >
                            <a id="menus" role="menuitem" tabindex="${item.userId}" href="#"  onclick="javascript:subgo('${item.userName}','${item.userId}')">${item.userName}</a>
                        </li>
                    </c:forEach>
                </ul>
            </div>
            <div class="col-sm-3">
            </div>
            <div class="col-sm-3">
                <button type="button" id="chooseUserBtn" class="btn btn-danger">指定人员</button>
            </div>
        </div>

        <div class="form-group">
                <label class="col-sm-3 control-label">通知内容：</label>
                <div class="col-sm-9">
                    <textarea id="content" name="content" rows="5" cols="30"></textarea>
                </div>
            </div>

   <div class="form-group">
        <div class="col-sm-3">
            <label class="control-label">上传文件：</label>
        </div>
        <div class="col-sm-7 input-group">
            <span id="workerInfoExcelSpan1">
                <input class="id-input-file-2" type="file" name="wordFile" id="wordFile" multiple="multiple">
            </span>
        </div>
       <%-- <button id="parseExcelBtn" type="button" class="btn btn-submit btn-danger" style="margin-right:30%">提交解析Excel</button>--%>
    </div>
    <div class="form-group text-center" id="loading"  style="display: none" >
        正在上传···<br>
        <img src="${basePath}/img/loading.gif"/>
    </div>
        <button id="submitBtn" type="button" class="btn btn-primary btn-submit">提交</button>
    </div>
    <div class="form-group text-left" >
        <ul style="list-style-type:none" >
            <h4><li><span style="color: blueviolet">文件上传注意事项:</span></li></h4>
            <h6>&nbsp;</h6>
            <h5><li><span style="color: blueviolet">&nbsp;&nbsp;&nbsp;&nbsp;1. word文档字体要求：仿宋；标题：二号；正文：三号;</span></li></h5>
            <h5><li><span style="color: blueviolet">&nbsp;&nbsp;&nbsp;&nbsp;2. 上传多个文件时请按住Ctrl键，且每次最多上传5个文件;</span></li></h5>
        </ul>

    </div>
</form>

<script src="${basePath}/js/common/jquery.form.js"></script>
<script src="${basePath}/plugins/jqGrid/jquery.jqGrid.min.js${VERSION}"></script>
<script src="${basePath}/plugins/jqGrid/grid.locale-cn.js${VERSION}"></script>
<script src="${basePath}/assets/js/ace-elements.min.js${VERSION}"></script>
<script src="${basePath}/js/common/jquery.validator.addmethod.js${VERSION}"></script>
<script type="text/javascript">

	var first = 0;
	var taskUserIsO = 0;
	var userIds = [];
	
	$("#panel-body-1").hide();

	var subgo = function(userName,alloterId){
		//alert(userName);
		$('#userName').val(userName);
		$('#alloterIds').val(alloterId);
	}
	
	
    jQuery(function ($) {
    	$("#chooseUserBtn").click("click", function () {
        	openOrg();
        });
        //选择部门
        function openOrg() {       	
            var pageii = layer.open({
                title: false,
                type: 2,
                area: ["800px", "600px"],
                content: ['${basePath}/notice/anon/toOrgTree']

            });
        }


        $('.date-icon').fdatepicker({
            format: 'yyyy-mm-dd'
        });

        $('#submitBtn').click("click", function () {
            var $form = $("#form");
            var $title = $("#title");//标题
            var $content = $("#content");//通知内容
            var $priority = $("#priority");//优先级
            var $submitBtn = $("#submitBtn");

            var title = $("#title").val();
            if (!title) {
                layer.alert("请填写标题")
                return false;
            }
                $("#form").attr("action", "${basePath}/notice/uploadFile.json")
                $("#form").ajaxSubmit({
                    dataType: "json",
                    beforeSubmit: function(){
                    $submitBtn.prop("disabled", true);
                },
                success: function (data) {
                    if (data.status == '0') {
                        $submitBtn.attr("disabled",true);
                        layer.alert('通知发送成功！', {icon: 1,closeBtn: 0}, function (index) {
                            parent.$("#grid-table").jqGrid().trigger("reloadGrid", [{page: 1}]);
                            parent.layer.close(parent.pageii);
                            return false
                        });
                    }
                    else if (data.status == '1') {
                        layer.alert(data.message, {
                            icon: 0,
                            skin: 'layui-layer-lan',
                            closeBtn: 0
                        });
                    }
                    else {
                        layer.alert("系统未知错误", {
                            icon: 0,
                            skin: 'layui-layer-lan',
                            closeBtn: 0
                        });
                    }
                },
                error: function (xhr, textStatus, errorThrown) {
                    layer.alert("系统未知错误", {
                        icon: 0,
                        skin: 'layui-layer-lan',
                        closeBtn: 0
                    });
                }
            });

        })

        $(document).ajaxStart(function(){
            $('#loading').show();
        }).ajaxStop(function(){
            $('#loading').hide();
        })


        $("#chooseUserBtn").click("click", function () {
            var rowData = $("#grid-table").jqGrid('getRowData', rowId);
            var id = rowData.funRoleId;

            pageii = layer.open({
                title: "选择用户",
                type: 2,
                area: ["400px", "500px"],
                content: '${basePath}/funRole/toChooseUser?funRoleId=' + id
            });

        });

    });
</script>
</body>
</html>
